package com.jokerku.lottery.domain.receive.engine;

import com.jokerku.lottery.domain.receive.filter.EventFilter;
import com.jokerku.lottery.infrastructure.common.EventEnum;
import com.jokerku.lottery.infrastructure.common.EventTypeEnum;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: guzq
 * @CreateTime: 2022/08/31 10:34
 * @Description: 事件引擎配置类
 * @Version: 1.0
 */
public abstract class EngineConfig {

    protected static final Map<EventTypeEnum, Map<EventEnum, EventFilter>> EVENT_FILTER_MAP = new ConcurrentHashMap<>();

    @Resource
    private EventFilter unSubscribe;
    @Resource
    private EventFilter subscribe;
    @Resource
    private EventFilter lottery;

    @PostConstruct
    private void init() {
        EVENT_FILTER_MAP.put(EventTypeEnum.EVENT, new HashMap<EventEnum, EventFilter>(){{
            put(EventEnum.SUBSCRIBE, subscribe);
            put(EventEnum.UNSUBSCRIBE, unSubscribe);
        }});

        EVENT_FILTER_MAP.put(EventTypeEnum.TEXT, new HashMap<EventEnum, EventFilter>(){{
            put(EventEnum.LOTTERY, lottery);
        }});
    }
}
